<extend name="./Application/Common/View/block/base.php" />
<block name="header">
    <include file="./Application/Admin/View/block/easyui_header.php" />
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=FGxlOGqzEZu5SDriE0hMYqFx"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.js"></script>
    <link rel="stylesheet" href="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.css" />
</block>
<block name="bdoy">
    <body>
    <div id="allmap" style="height: 100%;width: 100%;"></div>
    </body>
</block>
<block name="footExtendJs">
    <script type="text/javascript">
        // 百度地图API功能
        var map = new BMap.Map("allmap");
        map.enableScrollWheelZoom();
        var point = new BMap.Point({:get_kv_val('all_view_gps')});
        map.centerAndZoom(point, 14);
        // 编写自定义函数,创建标注
        function addMarker(point, title, render_url, icon_url){
            var myIcon = new BMap.Icon(icon_url, new BMap.Size(30,22));
            var marker = new BMap.Marker(point, {icon:myIcon});
            map.addOverlay(marker);
            var opts = {
                width : 50,     // 信息窗口宽度
                height: 30,     // 信息窗口高度
                title : title , // 信息窗口标题
                enableMessage:false,//设置允许信息窗发送短息
                message:title
            }
            var infoWindow = new BMap.InfoWindow("", opts);  // 创建信息窗口对象
            marker.addEventListener("mouseover", function(){
                this.openInfoWindow(infoWindow,point); //开启信息窗口
            });
            marker.addEventListener("mouseout", function(){
                this.closeInfoWindow(infoWindow,point); //关闭信息窗口
            });
            marker.addEventListener("click", function(){
               window.location.href = render_url;
            });
            return marker;
        }
        var pumpstations = new Array(<volist name="stations" id="station">'{$station['pups_point']}',</volist>'');
        var pumpstationnames =  new Array(<volist name="stations" id="station">'{$station['pups_name']}',</volist>'');
        var pumpstationids =  new Array(<volist name="stations" id="station">'{$station['id']}',</volist>'');
        var machines = new Array(<volist name="csdts" id="csdt">'{$csdt['csdt_point']}',</volist>'');
        var machinenames = new Array(<volist name="csdts" id="csdt">'{$csdt['csdt_name']}',</volist>'');
        var machineids = new Array(<volist name="csdts" id="csdt">'{$csdt['id']}',</volist>'');
        var gates = new Array(<volist name="gates" id="gate">'{$gate['gate_point']}',</volist>'');
        var gatenames = new Array(<volist name="gates" id="gate">'{$gate['gate_name']}',</volist>'');
        var gateids = new Array(<volist name="gates" id="gate">'{$gate['id']}',</volist>'');
        //添加泵站
        for (var i = 0; i < pumpstations.length; i ++) {
            if(pumpstations[i] == ''){
                continue;
            }
            var points = pumpstations[i].split(',');
            var point = new BMap.Point(points[0],points[1]);
            var marker = addMarker(point, pumpstationnames[i]
                ,'/Manage/AdminPumpStation/visualization?pid='+pumpstationids[i], '__PUBLIC__/module/manage/image/pump_icon.png');

        }
        //添加调蓄池
        for (var i = 0; i < machines.length; i ++) {
            if(machines[i] == ''){
                continue;
            }
            var points = machines[i].split(',');
            var point = new BMap.Point(points[0],points[1]);
            addMarker(point, machinenames[i]
                ,'/Manage/AdminCsdt/visualization?pid='+pumpstationids[i], '__PUBLIC__/module/manage/image/csdt_icon.png');
        }
        //添加闸门
        for (var i = 0; i < gates.length; i ++) {
            if(gates[i] == ''){
                continue;
            }
            var points = gates[i].split(',');
            var point = new BMap.Point(points[0],points[1]);
            addMarker(point, gatenames[i]
                ,'/Manage/AdminGate/visualization?pid='+pumpstationids[i], '__PUBLIC__/module/manage/image/gate_icon.png');
        }

    </script>


</block>
